package org.mzy.basic.controller;

import org.mzy.basic.service.IRegisterService;
import org.mzy.basic.util.AjaxResult;
import org.mzy.user.dto.EmailRegisterDto;
import org.mzy.user.dto.PhoneRegisterDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private IRegisterService registerService;


    /**
     * 手机号注册
     */
    @PostMapping("/phone")
    public AjaxResult phoneRegister(@RequestBody @Valid PhoneRegisterDto dto) {

        registerService.phoneRegister(dto);

        return AjaxResult.me().success();
    }

    /**
     * 邮箱注册
     */
    @PostMapping("/email")
    public AjaxResult emailRegister(@RequestBody @Valid EmailRegisterDto dto) {
        registerService.emailRegister(dto);
        return AjaxResult.me().success();
    }
}